package com.doodle.common.data;

import android.database.AbstractCursor;

import java.util.List;

public class BeanListCursor<T extends Bean> extends AbstractCursor {
	
	private final String[] mColumnNames;
	private List<T> mList;
	private Object mExtraData;
	
	public BeanListCursor(String[] columnNames) {
		mColumnNames = columnNames;
	}
	
	public void setList(List<T> list) {
		mList = list;
	}
	
	public List<T> getList() {
		return mList;
	}
	
	public T getBean() {
		return mList.get(mPos);
	}
	
	public void setExtraData(Object extraData) {
		mExtraData = extraData;
	}
	
	public Object getExtraData() {
		return mExtraData;
	}
	
	@Override
	public int getCount() {
		return mList == null ? 0 : mList.size();
	}

	@Override
	public String[] getColumnNames() {
		return mColumnNames;
	}

	@Override
	public String getString(int column) {
		return mList.get(mPos).getString(column);
	}

	@Override
	public short getShort(int column) {
		return mList.get(mPos).getShort(column);
	}

	@Override
	public int getInt(int column) {
		return mList.get(mPos).getInt(column);
	}

	@Override
	public long getLong(int column) {
		return mList.get(mPos).getLong(column);
	}

	@Override
	public float getFloat(int column) {
		return mList.get(mPos).getFloat(column);
	}

	@Override
	public double getDouble(int column) {
		return mList.get(mPos).getDouble(column);
	}
	
	@Override
	public byte[] getBlob(int column) {
		return mList.get(mPos).getBlob(column);
	}

	@Override
	public boolean isNull(int column) {
		return mList.get(mPos).isNull(column);
	}
	
}